﻿/**  版本信息模板在安装目录下，可自行修改。
* tbl_Protocol.cs
*
* 功 能： N/A
* 类 名： tbl_Protocol
*
* Ver    变更日期             负责人  变更内容
* ───────────────────────────────────
* V0.01  2014/1/14 22:01:05   N/A    初版
*
* Copyright (c) 2012 DocViewer Corporation. All rights reserved.
*┌──────────────────────────────────┐
*│　此技术信息为本公司机密信息，未经本公司书面同意禁止向第三方披露．　│
*│　版权所有：动软卓越（北京）科技有限公司　　　　　　　　　　　　　　│
*└──────────────────────────────────┘
*/
using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using DocViewer.DBUtility;//Please add references
namespace DY.DAL
{
	/// <summary>
	/// 数据访问类:tbl_Protocol
	/// </summary>
	public partial class tbl_Protocol
	{
		public tbl_Protocol()
		{}
		#region  BasicMethod

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
		return DbHelperSQL.GetMaxID("id", "tbl_Protocol"); 
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int id)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from tbl_Protocol");
			strSql.Append(" where id=@id");
			SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.Int,4)
			};
			parameters[0].Value = id;

			return DbHelperSQL.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int Add(DY.Model.tbl_Protocol model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into tbl_Protocol(");
			strSql.Append("ProtocolId,ProtocolType,OwnerId,Chai_Time,Chai_Structure,Chai_MainCovers,Chai_MainArea,Chai_AttachedCovers,Chai_AttachedArea,Chai_Fangqianwuhou,Chai_ReclamationLotNo,An_Type,An_Time,An_Address,An_HuXing,An_TaoShu,An_HouseNo,An_Covers,An_Area,An_ChaiJianNo,An_ChaiJianArea,An_GeLou,An_BuildType,Fei_FangKuanShuE,Fei_GeLouJinE,Fei_ChaiJianJinE,Fei_DiJiBuChaFei,Fei_ShiGongShuiDianFei,Fei_ShuiBiaoKaiHuFei,Fei_DianBiaoAnZhuangFei,Fei_LaJiQingYunFei,Fei_ShiGongBaoZhengJin,Fei_WeiYueFaKuan,Fei_DaiJianShuiNiYingHua,Fei_ChaiJiaJiangLi,Fei_AnZhiYanQiBuChang,Fei_ZhengCeXingBuZhu,Fei_GuoDuQiFangZu,Fei_YingJiaoShuE,Fei_YiJiaoShuE,Fei_WeiJiaoShuE,Fei_ChaiJiuFei,Fei_ShiJiaoFeiYong,Remark,ProtocolPhoto)");
			strSql.Append(" values (");
			strSql.Append("@ProtocolId,@ProtocolType,@OwnerId,@Chai_Time,@Chai_Structure,@Chai_MainCovers,@Chai_MainArea,@Chai_AttachedCovers,@Chai_AttachedArea,@Chai_Fangqianwuhou,@Chai_ReclamationLotNo,@An_Type,@An_Time,@An_Address,@An_HuXing,@An_TaoShu,@An_HouseNo,@An_Covers,@An_Area,@An_ChaiJianNo,@An_ChaiJianArea,@An_GeLou,@An_BuildType,@Fei_FangKuanShuE,@Fei_GeLouJinE,@Fei_ChaiJianJinE,@Fei_DiJiBuChaFei,@Fei_ShiGongShuiDianFei,@Fei_ShuiBiaoKaiHuFei,@Fei_DianBiaoAnZhuangFei,@Fei_LaJiQingYunFei,@Fei_ShiGongBaoZhengJin,@Fei_WeiYueFaKuan,@Fei_DaiJianShuiNiYingHua,@Fei_ChaiJiaJiangLi,@Fei_AnZhiYanQiBuChang,@Fei_ZhengCeXingBuZhu,@Fei_GuoDuQiFangZu,@Fei_YingJiaoShuE,@Fei_YiJiaoShuE,@Fei_WeiJiaoShuE,@Fei_ChaiJiuFei,@Fei_ShiJiaoFeiYong,@Remark,@ProtocolPhoto)");
			strSql.Append(";select @@IDENTITY");
			SqlParameter[] parameters = {
					new SqlParameter("@ProtocolId", SqlDbType.VarChar,150),
					new SqlParameter("@ProtocolType", SqlDbType.VarChar,50),
					new SqlParameter("@OwnerId", SqlDbType.Int,4),
					new SqlParameter("@Chai_Time", SqlDbType.Date,3),
					new SqlParameter("@Chai_Structure", SqlDbType.VarChar,50),
					new SqlParameter("@Chai_MainCovers", SqlDbType.Float,8),
					new SqlParameter("@Chai_MainArea", SqlDbType.Float,8),
					new SqlParameter("@Chai_AttachedCovers", SqlDbType.Float,8),
					new SqlParameter("@Chai_AttachedArea", SqlDbType.Float,8),
					new SqlParameter("@Chai_Fangqianwuhou", SqlDbType.Float,8),
					new SqlParameter("@Chai_ReclamationLotNo", SqlDbType.VarChar,50),
					new SqlParameter("@An_Type", SqlDbType.VarChar,50),
					new SqlParameter("@An_Time", SqlDbType.Date,3),
					new SqlParameter("@An_Address", SqlDbType.VarChar,50),
					new SqlParameter("@An_HuXing", SqlDbType.VarChar,50),
					new SqlParameter("@An_TaoShu", SqlDbType.Int,4),
					new SqlParameter("@An_HouseNo", SqlDbType.VarChar,50),
					new SqlParameter("@An_Covers", SqlDbType.Float,8),
					new SqlParameter("@An_Area", SqlDbType.Float,8),
					new SqlParameter("@An_ChaiJianNo", SqlDbType.VarChar,50),
					new SqlParameter("@An_ChaiJianArea", SqlDbType.Float,8),
					new SqlParameter("@An_GeLou", SqlDbType.Int,4),
					new SqlParameter("@An_BuildType", SqlDbType.VarChar,50),
					new SqlParameter("@Fei_FangKuanShuE", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_GeLouJinE", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ChaiJianJinE", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_DiJiBuChaFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ShiGongShuiDianFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ShuiBiaoKaiHuFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_DianBiaoAnZhuangFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_LaJiQingYunFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ShiGongBaoZhengJin", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_WeiYueFaKuan", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_DaiJianShuiNiYingHua", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ChaiJiaJiangLi", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_AnZhiYanQiBuChang", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ZhengCeXingBuZhu", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_GuoDuQiFangZu", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_YingJiaoShuE", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_YiJiaoShuE", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_WeiJiaoShuE", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ChaiJiuFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ShiJiaoFeiYong", SqlDbType.Decimal,9),
					new SqlParameter("@Remark", SqlDbType.VarChar,500),
					new SqlParameter("@ProtocolPhoto", SqlDbType.VarChar,80)};
			parameters[0].Value = model.ProtocolId;
			parameters[1].Value = model.ProtocolType;
			parameters[2].Value = model.OwnerId;
			parameters[3].Value = model.Chai_Time;
			parameters[4].Value = model.Chai_Structure;
			parameters[5].Value = model.Chai_MainCovers;
			parameters[6].Value = model.Chai_MainArea;
			parameters[7].Value = model.Chai_AttachedCovers;
			parameters[8].Value = model.Chai_AttachedArea;
			parameters[9].Value = model.Chai_Fangqianwuhou;
			parameters[10].Value = model.Chai_ReclamationLotNo;
			parameters[11].Value = model.An_Type;
			parameters[12].Value = model.An_Time;
			parameters[13].Value = model.An_Address;
			parameters[14].Value = model.An_HuXing;
			parameters[15].Value = model.An_TaoShu;
			parameters[16].Value = model.An_HouseNo;
			parameters[17].Value = model.An_Covers;
			parameters[18].Value = model.An_Area;
			parameters[19].Value = model.An_ChaiJianNo;
			parameters[20].Value = model.An_ChaiJianArea;
			parameters[21].Value = model.An_GeLou;
			parameters[22].Value = model.An_BuildType;
			parameters[23].Value = model.Fei_FangKuanShuE;
			parameters[24].Value = model.Fei_GeLouJinE;
			parameters[25].Value = model.Fei_ChaiJianJinE;
			parameters[26].Value = model.Fei_DiJiBuChaFei;
			parameters[27].Value = model.Fei_ShiGongShuiDianFei;
			parameters[28].Value = model.Fei_ShuiBiaoKaiHuFei;
			parameters[29].Value = model.Fei_DianBiaoAnZhuangFei;
			parameters[30].Value = model.Fei_LaJiQingYunFei;
			parameters[31].Value = model.Fei_ShiGongBaoZhengJin;
			parameters[32].Value = model.Fei_WeiYueFaKuan;
			parameters[33].Value = model.Fei_DaiJianShuiNiYingHua;
			parameters[34].Value = model.Fei_ChaiJiaJiangLi;
			parameters[35].Value = model.Fei_AnZhiYanQiBuChang;
			parameters[36].Value = model.Fei_ZhengCeXingBuZhu;
			parameters[37].Value = model.Fei_GuoDuQiFangZu;
			parameters[38].Value = model.Fei_YingJiaoShuE;
			parameters[39].Value = model.Fei_YiJiaoShuE;
			parameters[40].Value = model.Fei_WeiJiaoShuE;
			parameters[41].Value = model.Fei_ChaiJiuFei;
			parameters[42].Value = model.Fei_ShiJiaoFeiYong;
			parameters[43].Value = model.Remark;
			parameters[44].Value = model.ProtocolPhoto;

			object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(DY.Model.tbl_Protocol model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update tbl_Protocol set ");
			strSql.Append("ProtocolId=@ProtocolId,");
			strSql.Append("ProtocolType=@ProtocolType,");
			strSql.Append("OwnerId=@OwnerId,");
			strSql.Append("Chai_Time=@Chai_Time,");
			strSql.Append("Chai_Structure=@Chai_Structure,");
			strSql.Append("Chai_MainCovers=@Chai_MainCovers,");
			strSql.Append("Chai_MainArea=@Chai_MainArea,");
			strSql.Append("Chai_AttachedCovers=@Chai_AttachedCovers,");
			strSql.Append("Chai_AttachedArea=@Chai_AttachedArea,");
			strSql.Append("Chai_Fangqianwuhou=@Chai_Fangqianwuhou,");
			strSql.Append("Chai_ReclamationLotNo=@Chai_ReclamationLotNo,");
			strSql.Append("An_Type=@An_Type,");
			strSql.Append("An_Time=@An_Time,");
			strSql.Append("An_Address=@An_Address,");
			strSql.Append("An_HuXing=@An_HuXing,");
			strSql.Append("An_TaoShu=@An_TaoShu,");
			strSql.Append("An_HouseNo=@An_HouseNo,");
			strSql.Append("An_Covers=@An_Covers,");
			strSql.Append("An_Area=@An_Area,");
			strSql.Append("An_ChaiJianNo=@An_ChaiJianNo,");
			strSql.Append("An_ChaiJianArea=@An_ChaiJianArea,");
			strSql.Append("An_GeLou=@An_GeLou,");
			strSql.Append("An_BuildType=@An_BuildType,");
			strSql.Append("Fei_FangKuanShuE=@Fei_FangKuanShuE,");
			strSql.Append("Fei_GeLouJinE=@Fei_GeLouJinE,");
			strSql.Append("Fei_ChaiJianJinE=@Fei_ChaiJianJinE,");
			strSql.Append("Fei_DiJiBuChaFei=@Fei_DiJiBuChaFei,");
			strSql.Append("Fei_ShiGongShuiDianFei=@Fei_ShiGongShuiDianFei,");
			strSql.Append("Fei_ShuiBiaoKaiHuFei=@Fei_ShuiBiaoKaiHuFei,");
			strSql.Append("Fei_DianBiaoAnZhuangFei=@Fei_DianBiaoAnZhuangFei,");
			strSql.Append("Fei_LaJiQingYunFei=@Fei_LaJiQingYunFei,");
			strSql.Append("Fei_ShiGongBaoZhengJin=@Fei_ShiGongBaoZhengJin,");
			strSql.Append("Fei_WeiYueFaKuan=@Fei_WeiYueFaKuan,");
			strSql.Append("Fei_DaiJianShuiNiYingHua=@Fei_DaiJianShuiNiYingHua,");
			strSql.Append("Fei_ChaiJiaJiangLi=@Fei_ChaiJiaJiangLi,");
			strSql.Append("Fei_AnZhiYanQiBuChang=@Fei_AnZhiYanQiBuChang,");
			strSql.Append("Fei_ZhengCeXingBuZhu=@Fei_ZhengCeXingBuZhu,");
			strSql.Append("Fei_GuoDuQiFangZu=@Fei_GuoDuQiFangZu,");
			strSql.Append("Fei_YingJiaoShuE=@Fei_YingJiaoShuE,");
			strSql.Append("Fei_YiJiaoShuE=@Fei_YiJiaoShuE,");
			strSql.Append("Fei_WeiJiaoShuE=@Fei_WeiJiaoShuE,");
			strSql.Append("Fei_ChaiJiuFei=@Fei_ChaiJiuFei,");
			strSql.Append("Fei_ShiJiaoFeiYong=@Fei_ShiJiaoFeiYong,");
			strSql.Append("Remark=@Remark,");
			strSql.Append("ProtocolPhoto=@ProtocolPhoto");
			strSql.Append(" where id=@id");
			SqlParameter[] parameters = {
					new SqlParameter("@ProtocolId", SqlDbType.VarChar,150),
					new SqlParameter("@ProtocolType", SqlDbType.VarChar,50),
					new SqlParameter("@OwnerId", SqlDbType.Int,4),
					new SqlParameter("@Chai_Time", SqlDbType.Date,3),
					new SqlParameter("@Chai_Structure", SqlDbType.VarChar,50),
					new SqlParameter("@Chai_MainCovers", SqlDbType.Float,8),
					new SqlParameter("@Chai_MainArea", SqlDbType.Float,8),
					new SqlParameter("@Chai_AttachedCovers", SqlDbType.Float,8),
					new SqlParameter("@Chai_AttachedArea", SqlDbType.Float,8),
					new SqlParameter("@Chai_Fangqianwuhou", SqlDbType.Float,8),
					new SqlParameter("@Chai_ReclamationLotNo", SqlDbType.VarChar,50),
					new SqlParameter("@An_Type", SqlDbType.VarChar,50),
					new SqlParameter("@An_Time", SqlDbType.Date,3),
					new SqlParameter("@An_Address", SqlDbType.VarChar,50),
					new SqlParameter("@An_HuXing", SqlDbType.VarChar,50),
					new SqlParameter("@An_TaoShu", SqlDbType.Int,4),
					new SqlParameter("@An_HouseNo", SqlDbType.VarChar,50),
					new SqlParameter("@An_Covers", SqlDbType.Float,8),
					new SqlParameter("@An_Area", SqlDbType.Float,8),
					new SqlParameter("@An_ChaiJianNo", SqlDbType.VarChar,50),
					new SqlParameter("@An_ChaiJianArea", SqlDbType.Float,8),
					new SqlParameter("@An_GeLou", SqlDbType.Int,4),
					new SqlParameter("@An_BuildType", SqlDbType.VarChar,50),
					new SqlParameter("@Fei_FangKuanShuE", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_GeLouJinE", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ChaiJianJinE", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_DiJiBuChaFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ShiGongShuiDianFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ShuiBiaoKaiHuFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_DianBiaoAnZhuangFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_LaJiQingYunFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ShiGongBaoZhengJin", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_WeiYueFaKuan", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_DaiJianShuiNiYingHua", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ChaiJiaJiangLi", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_AnZhiYanQiBuChang", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ZhengCeXingBuZhu", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_GuoDuQiFangZu", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_YingJiaoShuE", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_YiJiaoShuE", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_WeiJiaoShuE", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ChaiJiuFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ShiJiaoFeiYong", SqlDbType.Decimal,9),
					new SqlParameter("@Remark", SqlDbType.VarChar,500),
					new SqlParameter("@ProtocolPhoto", SqlDbType.VarChar,80),
					new SqlParameter("@id", SqlDbType.Int,4)};
			parameters[0].Value = model.ProtocolId;
			parameters[1].Value = model.ProtocolType;
			parameters[2].Value = model.OwnerId;
			parameters[3].Value = model.Chai_Time;
			parameters[4].Value = model.Chai_Structure;
			parameters[5].Value = model.Chai_MainCovers;
			parameters[6].Value = model.Chai_MainArea;
			parameters[7].Value = model.Chai_AttachedCovers;
			parameters[8].Value = model.Chai_AttachedArea;
			parameters[9].Value = model.Chai_Fangqianwuhou;
			parameters[10].Value = model.Chai_ReclamationLotNo;
			parameters[11].Value = model.An_Type;
			parameters[12].Value = model.An_Time;
			parameters[13].Value = model.An_Address;
			parameters[14].Value = model.An_HuXing;
			parameters[15].Value = model.An_TaoShu;
			parameters[16].Value = model.An_HouseNo;
			parameters[17].Value = model.An_Covers;
			parameters[18].Value = model.An_Area;
			parameters[19].Value = model.An_ChaiJianNo;
			parameters[20].Value = model.An_ChaiJianArea;
			parameters[21].Value = model.An_GeLou;
			parameters[22].Value = model.An_BuildType;
			parameters[23].Value = model.Fei_FangKuanShuE;
			parameters[24].Value = model.Fei_GeLouJinE;
			parameters[25].Value = model.Fei_ChaiJianJinE;
			parameters[26].Value = model.Fei_DiJiBuChaFei;
			parameters[27].Value = model.Fei_ShiGongShuiDianFei;
			parameters[28].Value = model.Fei_ShuiBiaoKaiHuFei;
			parameters[29].Value = model.Fei_DianBiaoAnZhuangFei;
			parameters[30].Value = model.Fei_LaJiQingYunFei;
			parameters[31].Value = model.Fei_ShiGongBaoZhengJin;
			parameters[32].Value = model.Fei_WeiYueFaKuan;
			parameters[33].Value = model.Fei_DaiJianShuiNiYingHua;
			parameters[34].Value = model.Fei_ChaiJiaJiangLi;
			parameters[35].Value = model.Fei_AnZhiYanQiBuChang;
			parameters[36].Value = model.Fei_ZhengCeXingBuZhu;
			parameters[37].Value = model.Fei_GuoDuQiFangZu;
			parameters[38].Value = model.Fei_YingJiaoShuE;
			parameters[39].Value = model.Fei_YiJiaoShuE;
			parameters[40].Value = model.Fei_WeiJiaoShuE;
			parameters[41].Value = model.Fei_ChaiJiuFei;
			parameters[42].Value = model.Fei_ShiJiaoFeiYong;
			parameters[43].Value = model.Remark;
			parameters[44].Value = model.ProtocolPhoto;
			parameters[45].Value = model.id;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int id)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from tbl_Protocol ");
			strSql.Append(" where id=@id");
			SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.Int,4)
			};
			parameters[0].Value = id;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 批量删除数据
		/// </summary>
		public bool DeleteList(string idlist )
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from tbl_Protocol ");
			strSql.Append(" where id in ("+idlist + ")  ");
			int rows=DbHelperSQL.ExecuteSql(strSql.ToString());
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public DY.Model.tbl_Protocol GetModel(int id)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 id,ProtocolId,ProtocolType,OwnerId,Chai_Time,Chai_Structure,Chai_MainCovers,Chai_MainArea,Chai_AttachedCovers,Chai_AttachedArea,Chai_Fangqianwuhou,Chai_ReclamationLotNo,An_Type,An_Time,An_Address,An_HuXing,An_TaoShu,An_HouseNo,An_Covers,An_Area,An_ChaiJianNo,An_ChaiJianArea,An_GeLou,An_BuildType,Fei_FangKuanShuE,Fei_GeLouJinE,Fei_ChaiJianJinE,Fei_DiJiBuChaFei,Fei_ShiGongShuiDianFei,Fei_ShuiBiaoKaiHuFei,Fei_DianBiaoAnZhuangFei,Fei_LaJiQingYunFei,Fei_ShiGongBaoZhengJin,Fei_WeiYueFaKuan,Fei_DaiJianShuiNiYingHua,Fei_ChaiJiaJiangLi,Fei_AnZhiYanQiBuChang,Fei_ZhengCeXingBuZhu,Fei_GuoDuQiFangZu,Fei_YingJiaoShuE,Fei_YiJiaoShuE,Fei_WeiJiaoShuE,Fei_ChaiJiuFei,Fei_ShiJiaoFeiYong,Remark,ProtocolPhoto from tbl_Protocol ");
			strSql.Append(" where id=@id");
			SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.Int,4)
			};
			parameters[0].Value = id;

			DY.Model.tbl_Protocol model=new DY.Model.tbl_Protocol();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public DY.Model.tbl_Protocol DataRowToModel(DataRow row)
		{
			DY.Model.tbl_Protocol model=new DY.Model.tbl_Protocol();
			if (row != null)
			{
				if(row["id"]!=null && row["id"].ToString()!="")
				{
					model.id=int.Parse(row["id"].ToString());
				}
				if(row["ProtocolId"]!=null)
				{
					model.ProtocolId=row["ProtocolId"].ToString();
				}
				if(row["ProtocolType"]!=null)
				{
					model.ProtocolType=row["ProtocolType"].ToString();
				}
				if(row["OwnerId"]!=null && row["OwnerId"].ToString()!="")
				{
					model.OwnerId=int.Parse(row["OwnerId"].ToString());
				}
				if(row["Chai_Time"]!=null && row["Chai_Time"].ToString()!="")
				{
					model.Chai_Time=DateTime.Parse(row["Chai_Time"].ToString());
				}
				if(row["Chai_Structure"]!=null)
				{
					model.Chai_Structure=row["Chai_Structure"].ToString();
				}
				if(row["Chai_MainCovers"]!=null && row["Chai_MainCovers"].ToString()!="")
				{
					model.Chai_MainCovers=decimal.Parse(row["Chai_MainCovers"].ToString());
				}
				if(row["Chai_MainArea"]!=null && row["Chai_MainArea"].ToString()!="")
				{
					model.Chai_MainArea=decimal.Parse(row["Chai_MainArea"].ToString());
				}
				if(row["Chai_AttachedCovers"]!=null && row["Chai_AttachedCovers"].ToString()!="")
				{
					model.Chai_AttachedCovers=decimal.Parse(row["Chai_AttachedCovers"].ToString());
				}
				if(row["Chai_AttachedArea"]!=null && row["Chai_AttachedArea"].ToString()!="")
				{
					model.Chai_AttachedArea=decimal.Parse(row["Chai_AttachedArea"].ToString());
				}
				if(row["Chai_Fangqianwuhou"]!=null && row["Chai_Fangqianwuhou"].ToString()!="")
				{
					model.Chai_Fangqianwuhou=decimal.Parse(row["Chai_Fangqianwuhou"].ToString());
				}
				if(row["Chai_ReclamationLotNo"]!=null)
				{
					model.Chai_ReclamationLotNo=row["Chai_ReclamationLotNo"].ToString();
				}
				if(row["An_Type"]!=null)
				{
					model.An_Type=row["An_Type"].ToString();
				}
				if(row["An_Time"]!=null && row["An_Time"].ToString()!="")
				{
					model.An_Time=DateTime.Parse(row["An_Time"].ToString());
				}
				if(row["An_Address"]!=null)
				{
					model.An_Address=row["An_Address"].ToString();
				}
				if(row["An_HuXing"]!=null)
				{
					model.An_HuXing=row["An_HuXing"].ToString();
				}
				if(row["An_TaoShu"]!=null && row["An_TaoShu"].ToString()!="")
				{
					model.An_TaoShu=int.Parse(row["An_TaoShu"].ToString());
				}
				if(row["An_HouseNo"]!=null)
				{
					model.An_HouseNo=row["An_HouseNo"].ToString();
				}
				if(row["An_Covers"]!=null && row["An_Covers"].ToString()!="")
				{
					model.An_Covers=decimal.Parse(row["An_Covers"].ToString());
				}
				if(row["An_Area"]!=null && row["An_Area"].ToString()!="")
				{
					model.An_Area=decimal.Parse(row["An_Area"].ToString());
				}
				if(row["An_ChaiJianNo"]!=null)
				{
					model.An_ChaiJianNo=row["An_ChaiJianNo"].ToString();
				}
				if(row["An_ChaiJianArea"]!=null && row["An_ChaiJianArea"].ToString()!="")
				{
					model.An_ChaiJianArea=decimal.Parse(row["An_ChaiJianArea"].ToString());
				}
				if(row["An_GeLou"]!=null && row["An_GeLou"].ToString()!="")
				{
					model.An_GeLou=int.Parse(row["An_GeLou"].ToString());
				}
				if(row["An_BuildType"]!=null)
				{
					model.An_BuildType=row["An_BuildType"].ToString();
				}
				if(row["Fei_FangKuanShuE"]!=null && row["Fei_FangKuanShuE"].ToString()!="")
				{
					model.Fei_FangKuanShuE=decimal.Parse(row["Fei_FangKuanShuE"].ToString());
				}
				if(row["Fei_GeLouJinE"]!=null && row["Fei_GeLouJinE"].ToString()!="")
				{
					model.Fei_GeLouJinE=decimal.Parse(row["Fei_GeLouJinE"].ToString());
				}
				if(row["Fei_ChaiJianJinE"]!=null && row["Fei_ChaiJianJinE"].ToString()!="")
				{
					model.Fei_ChaiJianJinE=decimal.Parse(row["Fei_ChaiJianJinE"].ToString());
				}
				if(row["Fei_DiJiBuChaFei"]!=null && row["Fei_DiJiBuChaFei"].ToString()!="")
				{
					model.Fei_DiJiBuChaFei=decimal.Parse(row["Fei_DiJiBuChaFei"].ToString());
				}
				if(row["Fei_ShiGongShuiDianFei"]!=null && row["Fei_ShiGongShuiDianFei"].ToString()!="")
				{
					model.Fei_ShiGongShuiDianFei=decimal.Parse(row["Fei_ShiGongShuiDianFei"].ToString());
				}
				if(row["Fei_ShuiBiaoKaiHuFei"]!=null && row["Fei_ShuiBiaoKaiHuFei"].ToString()!="")
				{
					model.Fei_ShuiBiaoKaiHuFei=decimal.Parse(row["Fei_ShuiBiaoKaiHuFei"].ToString());
				}
				if(row["Fei_DianBiaoAnZhuangFei"]!=null && row["Fei_DianBiaoAnZhuangFei"].ToString()!="")
				{
					model.Fei_DianBiaoAnZhuangFei=decimal.Parse(row["Fei_DianBiaoAnZhuangFei"].ToString());
				}
				if(row["Fei_LaJiQingYunFei"]!=null && row["Fei_LaJiQingYunFei"].ToString()!="")
				{
					model.Fei_LaJiQingYunFei=decimal.Parse(row["Fei_LaJiQingYunFei"].ToString());
				}
				if(row["Fei_ShiGongBaoZhengJin"]!=null && row["Fei_ShiGongBaoZhengJin"].ToString()!="")
				{
					model.Fei_ShiGongBaoZhengJin=decimal.Parse(row["Fei_ShiGongBaoZhengJin"].ToString());
				}
				if(row["Fei_WeiYueFaKuan"]!=null && row["Fei_WeiYueFaKuan"].ToString()!="")
				{
					model.Fei_WeiYueFaKuan=decimal.Parse(row["Fei_WeiYueFaKuan"].ToString());
				}
				if(row["Fei_DaiJianShuiNiYingHua"]!=null && row["Fei_DaiJianShuiNiYingHua"].ToString()!="")
				{
					model.Fei_DaiJianShuiNiYingHua=decimal.Parse(row["Fei_DaiJianShuiNiYingHua"].ToString());
				}
				if(row["Fei_ChaiJiaJiangLi"]!=null && row["Fei_ChaiJiaJiangLi"].ToString()!="")
				{
					model.Fei_ChaiJiaJiangLi=decimal.Parse(row["Fei_ChaiJiaJiangLi"].ToString());
				}
				if(row["Fei_AnZhiYanQiBuChang"]!=null && row["Fei_AnZhiYanQiBuChang"].ToString()!="")
				{
					model.Fei_AnZhiYanQiBuChang=decimal.Parse(row["Fei_AnZhiYanQiBuChang"].ToString());
				}
				if(row["Fei_ZhengCeXingBuZhu"]!=null && row["Fei_ZhengCeXingBuZhu"].ToString()!="")
				{
					model.Fei_ZhengCeXingBuZhu=decimal.Parse(row["Fei_ZhengCeXingBuZhu"].ToString());
				}
				if(row["Fei_GuoDuQiFangZu"]!=null && row["Fei_GuoDuQiFangZu"].ToString()!="")
				{
					model.Fei_GuoDuQiFangZu=decimal.Parse(row["Fei_GuoDuQiFangZu"].ToString());
				}
				if(row["Fei_YingJiaoShuE"]!=null && row["Fei_YingJiaoShuE"].ToString()!="")
				{
					model.Fei_YingJiaoShuE=decimal.Parse(row["Fei_YingJiaoShuE"].ToString());
				}
				if(row["Fei_YiJiaoShuE"]!=null && row["Fei_YiJiaoShuE"].ToString()!="")
				{
					model.Fei_YiJiaoShuE=decimal.Parse(row["Fei_YiJiaoShuE"].ToString());
				}
				if(row["Fei_WeiJiaoShuE"]!=null && row["Fei_WeiJiaoShuE"].ToString()!="")
				{
					model.Fei_WeiJiaoShuE=decimal.Parse(row["Fei_WeiJiaoShuE"].ToString());
				}
				if(row["Fei_ChaiJiuFei"]!=null && row["Fei_ChaiJiuFei"].ToString()!="")
				{
					model.Fei_ChaiJiuFei=decimal.Parse(row["Fei_ChaiJiuFei"].ToString());
				}
				if(row["Fei_ShiJiaoFeiYong"]!=null && row["Fei_ShiJiaoFeiYong"].ToString()!="")
				{
					model.Fei_ShiJiaoFeiYong=decimal.Parse(row["Fei_ShiJiaoFeiYong"].ToString());
				}
				if(row["Remark"]!=null)
				{
					model.Remark=row["Remark"].ToString();
				}
				if(row["ProtocolPhoto"]!=null)
				{
					model.ProtocolPhoto=row["ProtocolPhoto"].ToString();
				}
			}
			return model;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select id,ProtocolId,ProtocolType,OwnerId,Chai_Time,Chai_Structure,Chai_MainCovers,Chai_MainArea,Chai_AttachedCovers,Chai_AttachedArea,Chai_Fangqianwuhou,Chai_ReclamationLotNo,An_Type,An_Time,An_Address,An_HuXing,An_TaoShu,An_HouseNo,An_Covers,An_Area,An_ChaiJianNo,An_ChaiJianArea,An_GeLou,An_BuildType,Fei_FangKuanShuE,Fei_GeLouJinE,Fei_ChaiJianJinE,Fei_DiJiBuChaFei,Fei_ShiGongShuiDianFei,Fei_ShuiBiaoKaiHuFei,Fei_DianBiaoAnZhuangFei,Fei_LaJiQingYunFei,Fei_ShiGongBaoZhengJin,Fei_WeiYueFaKuan,Fei_DaiJianShuiNiYingHua,Fei_ChaiJiaJiangLi,Fei_AnZhiYanQiBuChang,Fei_ZhengCeXingBuZhu,Fei_GuoDuQiFangZu,Fei_YingJiaoShuE,Fei_YiJiaoShuE,Fei_WeiJiaoShuE,Fei_ChaiJiuFei,Fei_ShiJiaoFeiYong,Remark,ProtocolPhoto ");
			strSql.Append(" FROM tbl_Protocol ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ");
			if(Top>0)
			{
				strSql.Append(" top "+Top.ToString());
			}
			strSql.Append(" id,ProtocolId,ProtocolType,OwnerId,Chai_Time,Chai_Structure,Chai_MainCovers,Chai_MainArea,Chai_AttachedCovers,Chai_AttachedArea,Chai_Fangqianwuhou,Chai_ReclamationLotNo,An_Type,An_Time,An_Address,An_HuXing,An_TaoShu,An_HouseNo,An_Covers,An_Area,An_ChaiJianNo,An_ChaiJianArea,An_GeLou,An_BuildType,Fei_FangKuanShuE,Fei_GeLouJinE,Fei_ChaiJianJinE,Fei_DiJiBuChaFei,Fei_ShiGongShuiDianFei,Fei_ShuiBiaoKaiHuFei,Fei_DianBiaoAnZhuangFei,Fei_LaJiQingYunFei,Fei_ShiGongBaoZhengJin,Fei_WeiYueFaKuan,Fei_DaiJianShuiNiYingHua,Fei_ChaiJiaJiangLi,Fei_AnZhiYanQiBuChang,Fei_ZhengCeXingBuZhu,Fei_GuoDuQiFangZu,Fei_YingJiaoShuE,Fei_YiJiaoShuE,Fei_WeiJiaoShuE,Fei_ChaiJiuFei,Fei_ShiJiaoFeiYong,Remark,ProtocolPhoto ");
			strSql.Append(" FROM tbl_Protocol ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			strSql.Append(" order by " + filedOrder);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM tbl_Protocol ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T.id desc");
			}
			strSql.Append(")AS Row, T.*  from tbl_Protocol T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			SqlParameter[] parameters = {
					new SqlParameter("@tblName", SqlDbType.VarChar, 255),
					new SqlParameter("@fldName", SqlDbType.VarChar, 255),
					new SqlParameter("@PageSize", SqlDbType.Int),
					new SqlParameter("@PageIndex", SqlDbType.Int),
					new SqlParameter("@IsReCount", SqlDbType.Bit),
					new SqlParameter("@OrderType", SqlDbType.Bit),
					new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
					};
			parameters[0].Value = "tbl_Protocol";
			parameters[1].Value = "id";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  BasicMethod
		#region  ExtensionMethod

		#endregion  ExtensionMethod
	}
}

